/**
* Tero Paananen
* tepaanan@gmail.com
* FINLAND
*/

#include <QtGui>
#include <QApplication>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDebug>
#include <QDeclarativeComponent>

// Lock Symbian orientation
#ifdef Q_OS_SYMBIAN
#include <eikenv.h>
#include <eikappui.h>
#include <aknenv.h>
#include <aknappui.h>
#endif

#include "serversocket.h"


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    qmlRegisterType<ServerSocket>("SocketItems", 1, 0, "ServerSocket");

    // Lock Symbian orientation
#ifdef Q_OS_SYMBIAN
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
    TRAP_IGNORE(
                if (appUi) {
                appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
        }
    );
#endif

    QDeclarativeView* view = new QDeclarativeView();
#ifdef Q_WS_MAEMO_5
    view->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
#endif

    view->setAutoFillBackground(false);
#ifdef Q_WS_MAEMO_5
    view->setSource(QUrl::fromLocalFile("/opt/electricityapp/qml/main.qml"));
#else
    view->setSource(QUrl::fromLocalFile("qml/main.qml"));
#endif
    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    QObject::connect((QObject*)view->engine(), SIGNAL(quit()), &a, SLOT(quit()));

#ifdef Q_OS_SYMBIAN
    view->showFullScreen();
//    view->showMaximized();
#elif defined Q_WS_MAEMO_5
    view->showMaximized();
#else
    view->setBaseSize(QSize(360,640));
    view->show();
#endif
    int ret = a.exec();
    delete view;
    return ret;
}
